﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            WriteRpg();
            Writeclass();

        }
        static void WriteRpg ()
        {
            Enum enum1 = new Enum();
            enum1.WriteJineng();
            enum1.CutFruit();
        }
        static void WriteEnum ()
        {
            Enum enum1 = new Enum();
            enum1.Writeenum();
        }
        public static void Writeclass() 
        {
            Class1 class1 = new Class1();

            class1.Student();
            class1.Name1 = "孙悟空";
            class1.Name2 = "猪八戒";
            class1.Name3 = "沙和尚";
            class1.Name4 = "白龙马";

            class1.Teacher = "唐僧";
            class1.Teacher2 = "嫦娥";

            for (int i = 0; i <= 1; i++)
            {
                if (i == 0)
                {
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name1, class1.Teacher);
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name2, class1.Teacher);
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name3, class1.Teacher);
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name4, class1.Teacher);
                }
                else {
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name1, class1.Teacher2);
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name2, class1.Teacher2);
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name3, class1.Teacher2);
                    Console.WriteLine("大家好,我是{0}，我的老师是{1}", class1.Name4, class1.Teacher2);
                }

            }


        }

        static void Writearrjudge() 
        {
            ArrayUtil arrayUtil = new ArrayUtil();
            arrayUtil.Arrjudge();

        }

        static void Writejudge()
        {
            StringUtil stringUtil = new StringUtil();
            stringUtil.judge();
        }
        public static void Write()
        {
            int max = 0;
            int min = 0;
            double avg = 0;
            int sum = 0;
            int[] arr1 = { 20, 80, 50 };
            Test1(arr1, ref max, ref min, ref avg, ref sum);
            //Test(arr1, out max, out min, out avg, out sum);
            Console.WriteLine("最大值为{0}，最小值为{1}，和为{2}，平均数为{3}", max, min, sum, avg);
        }

        static void Test1(int[] arr, ref int max, ref int min, ref double avg, ref int sum) //ref 要在类里初始化赋值，方法里不用必须赋值
        {
            max = arr[0];
            min = arr[0];
            foreach (var item in arr)
            {
                sum += item;
                if (item > max)
                {
                    max = item;
                }
                if (item < min)
                {
                    min = item;
                }
            }
            avg = sum / arr.Length;
        }


        //public static void Test(int[] arr, out int max, out int min, out double avg, out int sum) //out 不用初始化赋值，但必须在方法里赋值且出现
        //{
        //    max = arr[0];
        //    min = arr[0];
        //    avg = 0;
        //    sum = 0;
        //    for (int i = 0; i < arr.Length; i++)
        //    {
        //        sum += arr[i];
        //        if (arr[i] > max)
        //        {
        //            max = arr[i];
        //        }
        //        if (arr[i] < min)
        //        {
        //            min = arr[i];
        //        }
        //    }
        //    avg = sum * 1.0 / arr.Length;

        //}
    }

}
